package routers

import (
	"github.com/astaxie/beego"
	"neecola.com/learngo/family_security/controllers"
)

func init() {
	beego.Router("/index", &controllers.MainController{})
	beego.Router("/", &controllers.MainController{})

	// 移动版本的页面
	beego.Router("/m/index", &controllers.MainController{}, "get:M_Get")

	beego.ErrorController(&controllers.ErrorController{})

	user := beego.NewNamespace("/user",
		beego.NSNamespace("login",
			beego.NSRouter("/", &controllers.UserAction{}, "post:Login"),
		),
		// app 处理的配置
		beego.NSNamespace("/app",
			beego.NSRouter("/ws", &controllers.UserAction{}, "get:WsAppConnect"),
			// 测试 app的ws
			beego.NSRouter("/wstest", &controllers.UserAction{}, "get:AppWsTest"),
		),

		// 上位机处理
		beego.NSNamespace("/pr",
			beego.NSRouter("/ws", &controllers.UserAction{}, "get:WsPrConnect"),
			// 测试上位机的ws
			beego.NSRouter("/wstest", &controllers.UserAction{}, "get:PrWsTest"),
		),

		// 获取信息 gas tem
		beego.NSNamespace("/pick",
			beego.NSRouter("/info", &controllers.UserAction{}, "get:PickPass"),
		),
	)

	beego.AddNamespace(user)

	// 管理员的路由表
	admin := beego.NewNamespace("/admin",
		beego.NSNamespace("/login",
			beego.NSRouter("/", &controllers.AdminCtr{}, "get:Login"),
			beego.NSRouter("/", &controllers.AdminCtr{}, "post:LoginP"),
		),
		beego.NSNamespace("/op",
			beego.NSRouter("/", &controllers.AdminCtr{}, "get:ViewTotal"),
			beego.NSRouter("/fetch", &controllers.AdminCtr{}, "get:FetchData"),
			// 管理员退出登录
			beego.NSRouter("/exit", &controllers.AdminCtr{}, "get:Exit"),

			// 添加新的结点
			beego.NSRouter("/addnew", &controllers.AdminCtr{}, "get:AddMac"),
			beego.NSRouter("/addnew", &controllers.AdminCtr{}, "post:AddMacP"),

			// 添加新的子结点
			beego.NSRouter("/addsub", &controllers.AdminCtr{}, "get:AddSubMac"),
			beego.NSRouter("/addsub", &controllers.AdminCtr{}, "post:AddSubMacP"),
		),
	)
	// 管理员的路由
	beego.AddNamespace(admin)
}
